package {
	import flash.display.Graphics;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;

	/**
	 * ...
	 * @author jianping.shenjp
	 */
	public class Main extends Sprite {

		private var _sp:Sprite;

		public function Main():void {
			if (stage)
				init();
			else
				addEventListener(Event.ADDED_TO_STAGE, init);
		}

		private function init(e:Event = null):void {
			removeEventListener(Event.ADDED_TO_STAGE, init);
			// entry point
			_sp = new Sprite();
			_sp.x = _sp.y = 100;
			//_sp.addEventListener(MouseEvent.MOUSE_MOVE, spMouseOverHandler);
			_sp.addEventListener(MouseEvent.MOUSE_OUT, spMouseOutHandler);
			_sp.addEventListener(MouseEvent.ROLL_OVER, spRollOverHandler);
			_sp.addEventListener(MouseEvent.ROLL_OUT, spRollOutHandler);
			addChild(_sp);
			var g:Graphics = _sp.graphics;
			g.beginFill(0xFF0000);
			g.drawRect(0, 0, 50, 50);
			g.endFill();

			var _sp2:Sprite = new Sprite();
			//_sp2.addEventListener(MouseEvent.MOUSE_MOVE, spMouseOverHandler2);
			//_sp2.addEventListener(MouseEvent.MOUSE_OUT, spMouseOutHandler2);
			_sp.addChild(_sp2);
			var g2:Graphics = _sp2.graphics;
			g2.beginFill(0xFFFF00);
			g2.drawRect(0, 0, 40, 30);
			g2.endFill();
			//stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseOverHandler);
			stage.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
			//stage.addEventListener(MouseEvent.ROLL_OVER, rollOverHandler);
			stage.addEventListener(MouseEvent.ROLL_OUT, rollOutHandler);
			//stage.addEventListener(Event.MOUSE_LEAVE, mouseLeaveHandler);
		}
        
        private function spRollOutHandler(e:MouseEvent):void 
        {
            trace(" 2:    spRollOut spRollOut...");
        }
        
        private function spRollOverHandler(e:MouseEvent):void 
        {
            trace("     spRollOver spRollOver====...");
        }

		//private function spMouseOutHandler2(e:MouseEvent):void 
		//{
		//
		//}
		//
		//private function spMouseOverHandler2(e:MouseEvent):void 
		//{
		//
		//}

		private function rollOverHandler(e:MouseEvent):void {
			trace("1: rollOver");
		}

		private function rollOutHandler(e:MouseEvent):void {
			trace("1: rollOut  rollOut..");
		}

		private function mouseLeaveHandler(e:Event):void {
			trace("3: mouseLeaveHandler");
		}

		private function spMouseOutHandler(e:MouseEvent):void {
			trace(" 2:    spMouseOutHandler...");
		}

		private function spMouseOverHandler(e:MouseEvent):void {
			trace("     spMouseOverHandler====...");
		}

		private function mouseOutHandler(e:MouseEvent):void {
			trace("2: mouseOutHandler");
		}

		private function mouseOverHandler(e:MouseEvent):void {
			trace("mouseOverHandler....");
		}

	}

}